/**
 * Copyright (C) 2025 pony working team
 * SPDX-License-Identifier: MulanPSL-2.0
 */

/* includes (local) ----------------------------------------------------------*/
#include <hal_sys.h>
/* includes (standard library, system) ---------------------------------------*/
/* includes (other library) --------------------------------------------------*/
/* includes (project) --------------------------------------------------------*/
#include <x_config.h>
#include <x_errno.h>
#include <x_compiler.h>

/* defines -------------------------------------------------------------------*/
/* typedefs ------------------------------------------------------------------*/
/* macro ---------------------------------------------------------------------*/
/* variables (extern) --------------------------------------------------------*/
/* variables (local) ---------------------------------------------------------*/
/* variables (global) --------------------------------------------------------*/
/* inlines -------------------------------------------------------------------*/
/* functions -----------------------------------------------------------------*/

__weak int hal_sys_ioctl(int cmd, ...)
{
    return -ENOSYS;
}

#ifdef CONFIG_CMDER

#include <cmder.h>

static int __cmd_reboot(cmder_t *cmder, int argc, char *argv[])
{
    int ret = hal_sys_ioctl(HAL_SYS_CMD_REBOOT);
    if (ret != 0) {
        cmder_printf(cmder, "reboot failed, ret=%d\n", ret);
    }
    return ret;
}

CMDER_CMD_DEF("reboot", "reboot system", __cmd_reboot);

#endif
